package com.okbihuo.perm.mod.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.okbihuo.perm.core.mp.base.MyServiceImpl;
import com.okbihuo.perm.core.tool.utils.StringUtil;
import com.okbihuo.perm.mod.user.domain.AuthUser;
import com.okbihuo.perm.mod.user.mapper.AuthUserMapper;
import com.okbihuo.perm.mod.user.service.IAuthUserService;
import org.springframework.stereotype.Service;

@Service
public class AuthUserServiceImpl extends MyServiceImpl<AuthUserMapper, AuthUser> implements IAuthUserService {

    @Override
    public IPage pageAll(Page page, String keyword){
        QueryWrapper<AuthUser> wrapper = new QueryWrapper<>();
        if(StringUtil.isNotBlank(keyword)){
            wrapper.like("username",keyword).or().like("nickname",keyword);
        }
        wrapper.orderByDesc(StringUtil.humpToUnderline("createdDate"));
        return page(page,wrapper);
    }
}
